<?php


namespace App\Models;


use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

class CustomerEnterprises extends Model
{
    protected $fillable = ['name', 'ebc_code', 'ebc_name', 'ebp_code', 'ebp_name', 'assure', 'customer_id'];

    protected static function boot()
    {
        static::addGlobalScope('orderBy', function (Builder $query){
            $query->orderByDesc('id');
        });
        parent::boot();
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     * @author luffyzhao@vip.126.com
     */
    public function customer(){
        return $this->belongsTo(Customer::class);
    }
}
